from django.shortcuts import render_to_response
from django.conf import settings
from django.http import HttpResponseRedirect
from django.contrib.auth.decorators import login_required

import api

@login_required
def gae_cache_delete(request):
    a = api.Api()
    a.InvalidateAll()
    return HttpResponseRedirect('/admin/')

@login_required
def gae_cache_stats(request):
    a = api.Api()
    stats = a.Stats()

    stat_list = []
    for name in stats[2].keys():
        stat_list.append({'name': name, 'value': stats[2][name]})

    return render_to_response('gae_cache_stats.html', {'stats': stat_list})
